const Router = require('koa-router');
const router = new Router();
const {db, QueryTypes} = require("../../models/db");

router.post('/deliver/savePrintName', async ctx => {
    let tenantId = ctx.user.tenantId;
    let list = ctx.request.body.list;
    await db.transaction(async () => {
        await db.models['setPrint'].destroy({
            where: {
                tenantId: tenantId
            }
        })
        for (let i = 0; i < list.length; i++) {
            let it = list[i]
            await db.models['setPrint'].create({
                tenantId: tenantId,
                salePrintName: it.salePrintName,
                sendPrintName: it.sendPrintName,
            })
        }
    })
    return ctx.suc('打印机设置成功')
})




module.exports = router;
